﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using ProtoBuf;

namespace ProtobufTools
{
    public static class SerializerExtensions
    {
        public static bool CanSerializer(this Type t)
        {
            return Attribute.IsDefined(t, typeof(SerializableAttribute))
                || Attribute.IsDefined(t, typeof(XmlRootAttribute))
                || Attribute.IsDefined(t, typeof(ProtoContractAttribute))
                || t == typeof(IXmlSerializable);
        }

        public static bool IsXmlSerializer(this Type t)
        {
            return Attribute.IsDefined(t, typeof(XmlRootAttribute));
        }

        public static bool IsProtoBufSerializer(this Type t)
        {
            return Attribute.IsDefined(t, typeof(ProtoContractAttribute));
        }
    }
}
